<!DOCTYPE html>
<html> 
<head> 
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">  
    <title>检测耗材管理</title> 
    <link rel="shortcut icon" href="favicon.ico">
	<#import "/common/import.ftl" as import>
    <@import.tableManagerImportCss/>
    <link href="${WEB_PATH}/resources/js/plugins/fancybox/jquery.fancybox.css" rel="stylesheet">
 	<style>
    	.demo:after {
		    background-color: #F5F5F5;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px 0 4px 0;
		    color: #9DA0A4;
		    content: "条件查询：";
		    font-size: 12px;
		    font-weight: bold;
		    left: -1px;
		    padding: 3px 7px;
		    position: absolute;
		    top: -1px;
		}
		.demo {
		    margin-left: 0px;
		    padding:40px 15px 0px;
		    border: 1px solid #DDDDDD;
		    border-radius: 4px;
		    position: relative;
		    word-wrap: break-word;
		}
		.search{
		    width:300px;
		}
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <!-- Panel Other -->
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>检测耗材管理</h5>
                <div class="ibox-tools">
                </div>
            </div>
            <div class="ibox-content">
                <div class="row row-lg">  
                    <div class="col-sm-12">
                        <!-- Example Events -->
                        <div class="example-wrap"> 
                            <div class="example"> 
                            	<div style="" class="demo ui-sortable">
                            		 <div class="row">
			                            <div class="col-sm-3">
			                                <div class="form-group">
			                                    <label>所属检验机构：</label>
						                         <select data-placeholder="选择所属检验机构" id="tsorganizationInfoId" name="tsorganizationInfoId"  class="chosen-select form-control" >
								                   <option  value="" hassubinfo="true" ></option>
								                   <@tsorganizationInfos>
								                       <#list tsorganizationInfos as tsorganizationInfo >
													       <option value="${tsorganizationInfo.JYJGMC}" hassubinfo="true">${tsorganizationInfo.JYJGMC}</option>
													   </#list>
												   </@tsorganizationInfos>
												</select>
			                                </div> 
			                            </div>
			                            <div class="col-sm-3">
			                                <div class="form-group">
			                                    <label>耗材名称：</label>
			                                    <input name="NAME" id="NAME"   type="text"  class="form-control" placeholder="请输入耗材名称">
			                                </div> 
			                            </div>
			                           
			                            <div class="col-sm-3" style="padding-top: 22px;">
			                                 <button type="button" class="btn btn-primary" id="search">查询</button>
			                            </div> 
			                        </div>
			                    </div>
                                <div class="btn-group hidden-xs" id="exampleTableEventsToolbar" role="group">
                                	<@menuCheckInfo url = "/reg/consumables/add.do">
	                                	<#if urlCheck == true>
	                                  	<button type="button" class="btn btn-outline btn-default" data-toggle="modal" id="add" >
			                            	<i class="glyphicon glyphicon-plus" aria-hidden="true"></i>&nbsp;&nbsp;新增
			                            </button>
	                                    </#if>
                                    </@menuCheckInfo>
                                    
                                    <@menuCheckInfo url = "/reg/consumables/edit.do">
	                                	<#if urlCheck == true>
	                                     <button type="button" class="btn btn-outline btn-default" data-toggle="modal" id="edit" >
			                                <i class="glyphicon glyphicon-edit" aria-hidden="true"></i>&nbsp;&nbsp;修改
			                            </button>
	                                    </#if>
                                    </@menuCheckInfo>
                                    
                                      <@menuCheckInfo url = "/reg/consumables/remove.do">
	                                	<#if urlCheck == true>
	                                      <button type="button" class="btn btn-outline btn-default" data-toggle="modal" id="del" >
			                                <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>&nbsp;&nbsp;删除
			                              </button>
	                                    </#if>
                                    </@menuCheckInfo>
                                </div>
                                <table id="exampleTableEvents" >
                                    <thead>
                                        <tr>
                                            <th data-field="state" data-radio="true"></th>  
                                            <th data-field="id" data-visible = "false" >id</th>  
								            <th data-field="jyjgmc" >检验机构名称</th> 
								            <th data-field="name" >检测耗材名称</th> 
								            <th data-field="xh">型号</th> 
								            <th data-field="pp">品牌</th> 
								            <th data-field="yt">用途</th>
								            <th data-field="cjsj"data-formatter="formatTime">创建日期</th> 
                                        </tr>
                                    </thead>
                                </table>
                            </div>
                        </div>
                        <!-- End Example Events -->
                    </div>
                </div>
            </div>
        </div>
        <!-- End Panel Other -->
    </div>
    
    <div id="aut_win"></div>
    <@import.tableManagerImportScript/>
    <script src="${WEB_PATH }/resources/js/plugins/fancybox/jquery.fancybox.js"></script>
    <script src="${WEB_PATH}/resources/js/city-picker.data.js"></script>
	<script src="${WEB_PATH}/resources/js/city-picker.js"></script>
    <script >
    	$(function(){
    		$("#JYJGIDS").chosen({width:'100%'});
    		$(window).resize(function () {
		        $('#exampleTableEvents').bootstrapTable('resetView');
		    });
		   
		    function queryParams(params) {
		        var temp = {  
			        limit: params.limit,  
			        offset: params.offset, 
			        NAME:$("#NAME").val(),
			        JYJGMC:$("#tsorganizationInfoId").val(),
			        maxrows: params.limit,
			        pageindex:params.pageNumber,
		        };
		        return temp;
			}
    		//加载table数据
	    	$("#exampleTableEvents").bootstrapTable({
	            url: "${WEB_PATH }/reg/consumables/getPage.do",
	            method: 'get',
	            search:true,
	            pagination:true,
	            pageNumber:1,  
	            pageSize:10,   
	            showRefresh:true, 
	            showColumns:true,
	            iconSize: "outline",
	            toolbar: "#exampleTableEventsToolbar",
	            sidePagination: "server", //设置为服务器端分页
	            queryParams: queryParams,//参数
	            minimumCountColumns: 1, 
	            search: false,    //隐藏搜索框
	            clickToSelect: true,
	        });
	        
	        $('input.form-control.input-outline').hide();
	        
        });
        
         //点击查询搜索
		$("#search").click(function(){
			$("#exampleTableEvents").bootstrapTable('refresh');
		});
        
        
        function success(result){  
			if(result.success == true){ 
				swal({
			        title: "操作成功",
			        text: result.msg
		    	})
		    	$("#exampleTableEvents").bootstrapTable('refresh');
			}else{
				$('#saveBut').attr("disabled",false);    
				swal({
			        title: "操作失败",
			        text: result.msg
		    	})
			}
		}
		
		function formatterXB(val){
			var auditName = "";
			if(val == "0"){
				auditName = '男';
			}else if(val == "1"){
				auditName = '女';
			}
			return auditName;
		}
		
		function formatTime(val){
		 	var tt=new Date(val).toLocaleDateString().replace(/年|月/g,"-").replace(/日/g," ");; 
    		return tt; 
		}
		
		//点击新增按钮
		$("#add").click(function(){
			layer.open({
			      type: 2,
			      title: '<span style="color: #ed5565">新增检测耗材</span>',
			      shadeClose: false, 
			      shade: 0.3,
			      maxmin: false, //开启最大化最小化按钮
			      area: ['30%', '55%'],
			      content: "${WEB_PATH }/reg/consumables/view/add.do",
			      btn: ['确定','取消'],
			      yes: function(index, layero){
				      var body = layer.getChildFrame('body', index);
				      var iframeWin = window[layero.find('iframe')[0]['name']];
				      iframeWin.saveAddForm();
				  },
				  cancel: function(){
					  layer.closeAll();
				  }
			});
		});
		
		
	     //点击修改按钮
		$("#edit").click(function(){
		    var selectRow = $("#exampleTableEvents").bootstrapTable('getSelections');
            var info = selectRow[0]; 
        	if(1 != selectRow.length){
			    layer.msg('请选择您需要修改的检测耗材信息！', {icon: 5}); 
			    return ;
	       	} 
			layer.open({
			      type: 2,
			      title: '<span style="color: #ed5565">修改检测耗材</span>',
			      shadeClose: false, 
			      shade: 0.3,
			      maxmin: false, //开启最大化最小化按钮
			      area: ['30%', '55%'],
			      content: "${WEB_PATH }/reg/consumables/view/edit.do?id="+info.id,
			      btn: ['确定','取消'],
			      yes: function(index, layero){
				      var body = layer.getChildFrame('body', index);
				      var iframeWin = window[layero.find('iframe')[0]['name']];
				      iframeWin.saveEditForm();
				  },
				  cancel: function(){
					  layer.closeAll();
				  }
			});
		});
		
		
		 //删除检测机线
	     $('#del').click(function () {
        	var selectRow = $("#exampleTableEvents").bootstrapTable('getSelections');
        	if(0 == selectRow.length){
			    layer.msg('请选择您需要删除的检测耗材信息！', {icon: 5}); 
			    return ;
        	}
        	
        	layer.confirm('<span style="color: red">您确定要删除该数据?</span>',{icon: 3, title:'系统提示',btn: ['确认','取消']},
    		function(){
        		$.yilinAjax({
				   	  	type:'GET',
				   	  	url:'${WEB_PATH }/reg/consumables/remove.do?ID=' + selectRow[0].id, 
				   	  	data:null,
	            		errorcallback:null,
	            		successcallback:success
				});
			});
		});
        
    </script>
</body>

</html>